package test.testcase.dao;

import test.utils.JsonResult;
import test.utils.Mysql;

public class preurlDao {
	
	public static JsonResult getList(int start, int end, String projectid) {
		return Mysql.select("SELECT a.url,a.projectid,a.projectname AS projectnamekey,b.`projectname` FROM url a LEFT JOIN project b ON a.`projectid`=b.`id` WHERE b.`id`="+projectid+" LIMIT "+start+","+end);
	}
	
	public static JsonResult getList(String projectid) {
		return Mysql.select("SELECT * from url where projectid="+projectid);
	}

	public static JsonResult add(String projectid, String projectname, String preurl) {
		return Mysql.excute("insert into url (projectid,projectname,url) values("+projectid+",'"+projectname+"','"+preurl+"')");
	}
	
	public static JsonResult del(String projectname, String projectid) {
		return Mysql.excute("delete from url where projectname='"+projectname+"' and projectid="+projectid);
	}
	
	public static JsonResult getInfo(String projectid, String projectname) {
		return Mysql.select("select * from url where projectid="+projectid+" and projectname='"+projectname+"'");
	}
	
	public static JsonResult save(String projectid, String projectname, String preurl) {
		return Mysql.excute("update url set url='"+preurl+"' where projectid="+projectid+" and projectname='"+projectname+"'");
	}
	
}
